package cn.com.yiqi.wsc.dao.customer;

import cn.com.yiqi.wsc.Ro.CustomerRo;
import cn.com.yiqi.wsc.Ro.SimpleDistributionVO;
import cn.com.yiqi.wsc.dao.customer.criteria.CustomerCriteria;
import cn.com.yiqi.wsc.dao.customer.criteria.CustomerListCriteria;
import cn.com.yiqi.wsc.dao.point.entity.PointRecordEntity;
import cn.com.yiqi.wsc.entity.customer.Customer;
import cn.com.yiqi.wsc.entity.customer.CustomerExample;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface CustomerMapper {


    int insertSelective(Customer record);

    List<Customer> selectByExample(CustomerExample example);

    Customer selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Customer record);

    CustomerRo findByOpenIdRegist(String openid);

    CustomerRo findByOpenId(@Param("openId") String openid, @Param("id") Integer id);

    Customer isExist(Integer id);

    Boolean haveLiked(@Param("userId") Integer userId, @Param("itemId") Integer itemId);

    void like(@Param("userId") Integer userId, @Param("itemId") Integer itemId, @Param("likeTime") Date date);

    Integer cancelLike(@Param("userId") Integer userId, @Param("itemId") Integer itemId);

    Long isExsitMobile(@Param("mobile") String mobile, @Param("userId") Integer userId);

    /**
     * �������
     *
     * @param balance
     * @param customerId
     * @return
     */
    Integer addBalance(@Param("balance") BigDecimal balance, @Param("customerId") Integer customerId);

    List<CustomerRo> selectCustomerList(CustomerListCriteria customerListCriteria);

    Integer updateCustomerStatus(CustomerCriteria customerCriteria);

    Integer deletCustomerByCustomerId(CustomerCriteria customerCriteria);

    List<SimpleDistributionVO> selectBySeq(CustomerListCriteria customerListCriteria);


    List<Customer> findByPid(Integer userId);

    Integer findByLevelId(@Param("sql") String sql);

    Integer updateCustomerPointByCustomerId(Customer customer);

    /**
     * 扣积分
     *
     * @param id
     * @param point
     * @return
     */
    Integer minusCustomerPointByCustomerId(@Param("id") Integer id, @Param("point") Integer point);

    Integer updateCustomerParam(CustomerRo customerRo);
}